#include<iostream>
using namespace std;
int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int** arr = new int* [2];
		for (int j = 0; j < 2; j++) {
			arr[j] = new int[3];
		}
		for (int k = 0; k < 2; k++) {
			for (int l = 0; l < 3; l++) {
				cin >> arr[k][l];
			}
		}
		for (int k = 2; k >= 0; k--) {
			for (int l = 0; l < 2; l++) {
				if (l == 0) {
					cout << arr[l][k] << ' ';
				}
				else {
					cout << arr[l][k] << ' ' << endl;
				}
			}
		}
		for (int j = 0; j < 2; j++) {
			delete[] arr[j];
		}
		delete[] arr;
	}
	return 0;
}